package com.balabala.gym_system.controller.admin;

import com.balabala.gym_system.pojo.dto.Message;
import com.balabala.gym_system.service.MessageService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/message")
@CrossOrigin
@Api(tags = "聊天接口")
public class MessageController {

    @Autowired
    private MessageService messageService;


    @GetMapping("/list")
    @ApiOperation(value = "拉取消息列表")
  public Result queryMessageList(@RequestParam("fromId") Long fromId,
                                   @RequestParam("toId") Long toId,
                                   @RequestParam(value = "page",
                                                  defaultValue = "1") Integer page,
                                   @RequestParam(value = "rows",
                                                  defaultValue = "10") Integer rows) {
        List<Message> messageList = messageService.queryMessageList(fromId, toId, page, rows);
        return Result.ok(messageList);
    }

}
